package org.zoomdev.zoom.common.caster;

import java.lang.reflect.ParameterizedType;

public abstract class ParameterizedTypeCasterFactory {
    private final Class<?> src;


    public ParameterizedTypeCasterFactory(Class<?> src) {
        this.src = src;
    }

    public boolean is(Object obj, ParameterizedType targetType) {
        return src.isInstance(obj) && accept(targetType);
    }

    public boolean is(Class<?> srcType, ParameterizedType targetType) {
        return src.isAssignableFrom(srcType) && accept(targetType);
    }

    protected abstract boolean accept(ParameterizedType targetType);

    protected abstract ValueCaster create(ParameterizedType targetType);
}
